$origin-width: 19px;
$origin-height: 19px;
$origin-long: 66px;
$ratio: 7;
$bar-bottom-gap: 8; // 横条距离底部8cm

$hou: 0.5px;

$rect-width: $origin-width * $ratio;
$rect-height: $origin-height * $ratio;
$rect-long: $origin-long * $ratio;
$rect-ratio: $ratio * 1px;

$label-color: red;
$border-color: #ccc;
$border: 1px solid $border-color;

.h1 {
  margin: 10px 0;
}
.container {
  height: 100vh;
}
.perspective-box {
  width: 650px;
  height: 500px;
  position: relative;
  perspective: 1200px;
}
// .perspective-box:hover {
//   .left {
//     left: 64px;
//   }
//   .right {
//     left: 398px;
//   }
//   .bottom {
//     top: 282px;
//   }
//   .front {
//     transform: translateZ(266.5px);
//   }
//   .back {
//     transform: translateZ(-266.5px) rotateY(180deg);
//   }
// }

.cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-15deg) rotateY(0deg) translateZ(100px);
  // transform: rotateX(-15deg) rotateY(-85deg) translateZ(100px);
  animation: rotate 20s infinite linear;
  &:hover {
    animation-play-state: paused;
  }
  .hole {
    position: absolute;
    border-radius: 50%;
    background-color: #fff;
    width: 1.5 * $rect-ratio; /* 1.5cm scaled */
    height: 1.5 * $rect-ratio;
  }
  .lab-top {
    position: absolute;
    top: -1.5 * $rect-ratio;
    left: 0.73 * $rect-ratio;
    color: $label-color;
    font-size: 12px;
    &::before {
      content: "";
      display: block;
      width: 1px;
      height: 2.4 * $rect-ratio;
      margin-right: 0.5em;
      background: $label-color;
    }
  }
  .lab-bot {
    position: absolute;
    bottom: -4.5 * $rect-ratio;
    left: 0.75 * $rect-ratio;
    color: $label-color;
    font-size: 12px;
    &::before {
      content: "";
      display: block;
      width: 1px;
      height: 5.3 * $rect-ratio;
      margin-right: 0.5em;
      background: $label-color;
    }
  }
}
@keyframes rotate {
  0% {
    transform: rotateX(-15deg) rotateY(0deg) translateZ(100px);
  }
  100% {
    transform: rotateX(-15deg) rotateY(360deg) translateZ(100px);
  }
}
.face {
  position: absolute;
  border: $border;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #333;
  background-color: rgba(255, 255, 255, 0.7);
  // box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  transition: all 1s ease-in-out;
  .lab-h {
    position: absolute;
    top: -2em;
    width: 100%;
    color: #000;
    &::before,
    &::after {
      content: "";
      display: block;
      height: 1px;
      flex: 1;
      background: $label-color;
    }
    &::before {
      margin-right: 0.3em;
    }
    &::after {
      margin-left: 0.3em;
    }
  }
  .lab-v {
    position: absolute;
    top: 0;
    left: -4em;
    height: 100%;
    color: #000;
    &::before,
    &::after {
      content: "";
      display: block;
      width: 1px;
      height: 50%;
      flex: 1;
      background: $label-color;
    }
    &::before {
      margin-bottom: 0.3em;
    }
    &::after {
      margin-top: 0.3em;
    }
  }
}
/* 前后面 - 66x19 cm */
.front,
.back {
  width: $rect-long; /* 66cm scaled */
  height: $rect-height; /* 19cm scaled */
}
.front {
  transform: translateZ(66.5px);
  background-color: rgba(173, 216, 230, 0.8);
  left: 100px;
  top: 183px;
}
.back {
  transform: translateZ(-66.5px) rotateY(180deg);
  background-color: rgba(173, 216, 230, 0.6);
  left: 100px;
  top: 183px;
}
/* 左右面 - 19x19 cm - 调整间距 */
.right,
.left {
  width: $rect-width; /* 19cm scaled */
  height: $rect-height; /* 19cm scaled */
  background: rgba(#000, 0.7);
}
.right {
  transform: rotateY(90deg) translateZ(297.5px) translateX(0);
  left: 198px; /* 398px */
  top: 183px;
}
.left {
  transform: rotateY(-90deg) translateZ(231px) translateX(0);
  left: 264px; /*64px*/
  top: 183px;
}
/* 顶部 - 调整间距 */
.top {
  width: $rect-long; /* 66cm scaled */
  height: $rect-width; /* 19cm scaled */
  transform: rotateX(-90deg) translateZ(66.5px);
  // background-color: pink !important;
  left: 100px;
  &.one {
    top: 182px - 18.7 * $rect-ratio; /*282px*/
  }
  &.two {
    top: 182px - 9 * $rect-ratio; /*282px*/
  }
}
/* 底面 - 调整间距 */
.bottom {
  width: $rect-long; /* 66cm scaled */
  height: $rect-width; /* 19cm scaled */
  transform: rotateX(-90deg) translateZ(66.5px);
  background-color: rgba(255, 182, 193, 0.5);
  left: 100px;
  top: 182px; /*282px*/
}
/* 内部结构 */
.inner-element {
  position: absolute;
  background-color: #aaa;
  /* 横条 */
  &.horizontal-bar {
    height: $rect-ratio; /* 0.5cm scaled */
    width: $rect-long; /* 66cm scaled */
    left: 0;
    &.bar-1 {
      top: 0.5 * $rect-ratio; /* 17.5cm from bottom scaled */
    }
    &.bar-2 {
      bottom: $bar-bottom-gap * $rect-ratio; /* 9cm from bottom scaled */
    }
  }
}

/* 圆孔 */
.left-hole {
  left: 50%; /* 水平居中 */
  transform: translateX(-50%);
  top: 1.5 * $rect-ratio; /* 3cm from top scaled */
}
.right-hole-top {
  left: 50%;
  transform: translateX(-50%);
  top: 1.5 * $rect-ratio;
}
.right-hole-bottom {
  left: 50%;
  transform: translateX(-50%);
  bottom: 4.5 * $rect-ratio; /* 6cm from bottom scaled */
}
/* 标注 */
.dimension-label {
  position: absolute;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 3px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  color: #333;
  border: $border;
}
.front-label {
  bottom: 5px;
  right: 5px;
}
.right-label {
  bottom: 50%;
  right: 50%;
  transform: translate(50%, 50%);
}
/* 横板示意图 - 5-4-5-4-5排列 */
.panel-container {
  width: 700px;
  overflow: auto;
  padding: 15px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
}

.water-panel {
  position: relative;
  width: $rect-long - $rect-ratio; /* 66cm scaled */
  height: $rect-width - $rect-ratio; /* 18cm scaled */
  border: $border;
  background: $border-color;
  .lab-h {
    position: absolute;
    top: -1.6em;
    width: 100%;
    color: #000;
    &::before,
    &::after {
      content: "";
      display: block;
      height: 1px;
      flex: 1;
      background: $label-color;
    }
    &::before {
      margin-right: 0.3em;
    }
    &::after {
      margin-left: 0.3em;
    }
  }
  .lab-v {
    position: absolute;
    top: 0;
    left: -6.9em;
    height: 100%;
    color: #000;
    &::before,
    &::after {
      content: "";
      display: block;
      width: 1px;
      height: 50%;
      flex: 1;
      background: $label-color;
    }
    &::before {
      margin-bottom: 0.3em;
    }
    &::after {
      margin-top: 0.3em;
    }
  }
  .hole {
    // position: absolute;
    border-radius: 50%;
    width: 1.2 * 2 * $rect-ratio; /* 1.2cm scaled */
    height: 1.2 * 2 * $rect-ratio;
    background-color: #fff;
  }
  .section {
    position: relative;
    height: 100%;
    padding: 2 * $rect-ratio;
    // box-sizing: border-box;
    &:not(:last-child) {
      border-right: 1px dashed #fff;
    }
    .slot {
      $radius: 1 * $rect-ratio;
      position: absolute;
      width: 1 * $rect-ratio;
      height: 6 * $rect-ratio;
      background: #fff;
      top: 50%;
      transform: translateY(-50%);
      z-index: -1;
      &:nth-child(1) {
        left: -1px;
        border-radius: 0 $radius$radius 0;
      }
      &:nth-last-child(1) {
        right: -1px;
        border-radius: $radius 0 0 $radius;
      }
    }
    // .mask {
    //   $one-unit: 1 * $rect-ratio;
    //   position: absolute;
    //   top: $one-unit;
    //   left: 0;
    //   padding: 1 * $rect-ratio;
    //   width: 100%;
    //   height: (18 - 2) * $one-unit;
    //   background: #aaa;
    //   & > .row {
    //     &:nth-child(2n + 1) {
    //       padding: 0 1 * $rect-ratio;
    //     }
    //     &:nth-child(2n) {
    //       padding: 0 3 * $rect-ratio;
    //     }
    //   }
    // }
    .mask {
      $one-unit: 1 * $rect-ratio;
      position: absolute;
      top: 0;
      left: 0;
      padding: 2 * $rect-ratio $one-unit;
      width: 100%;
      height: 18 * $one-unit;
      background: $border-color;
      .bar {
        position: absolute;
        top: $one-unit;
        background: #999;
        height: (18-2) * $rect-ratio;
        width: 2 * $one-unit;
        &.one {
          left: 0; // $one-unit;
        }
        &.two {
          right: 0; // $one-unit;
        }
      }
      & > .row {
        &:nth-child(2n + 1) {
          padding: 0 1 * $rect-ratio;
        }
        &:nth-child(2n) {
          padding: 0 3 * $rect-ratio;
        }
      }
    }
    & > .row {
      &:nth-child(2n + 1) {
        padding: 0 2 * $rect-ratio;
      }
    }
    // .bar {
    //   $one-unit: 1 * $rect-ratio;
    //   position: absolute;
    //   background: #aaa;
    //   z-index: 2;
    //   &.first {
    //     top: $one-unit;
    //     left: $one-unit;
    //     height: $one-unit;
    //     width: (65/3 - 2) * $one-unit;
    //     background: transparent;
    //   }
    //   &.second {
    //     top: $one-unit;
    //     right: $one-unit;
    //     width: $one-unit;
    //     height: (18 - 2) * $one-unit;
    //   }
    //   &.third {
    //     bottom: $one-unit;
    //     left: $one-unit;
    //     height: $one-unit;
    //     width: (65/3 - 2) * $one-unit;
    //     background: transparent;
    //   }
    //   &.fourth {
    //     top: $one-unit;
    //     left: $one-unit;
    //     width: $one-unit;
    //     height: (18 - 2) * $one-unit;
    //   }
    // }
  }
}
.panel-title {
  text-align: center;
  margin-bottom: 15px;
  color: #333;
}
/* 尺寸标注 */
.panel-dimension {
  text-align: center;
  font-size: 12px;
  margin: 5px 0;
  color: #555;
}
/* 水箱配置 */
.water-tank {
  margin-top: 20px;
  padding: 15px;
  border: 1px solid #ddd;
  background-color: #f0f8ff;
  border-radius: 5px;
  h3 {
    margin-top: 0;
    color: #2a5885;
  }
  p {
    margin: 8px 0;
    font-size: 14px;
  }
}

/* 说明部分 */
.notes {
  margin-top: 20px;
  padding: 15px;
  background-color: #fffaf0;
  border-radius: 5px;
  border: 1px solid #eee8aa;
  h3 {
    margin-top: 0;
    color: #8b4513;
  }
  ul {
    padding-left: 20px;
    font-size: 14px;
  }
  li {
    margin-bottom: 8px;
  }
}

.highlight {
  background-color: #fffacd;
  padding: 2px 4px;
  border-radius: 3px;
}

.face-demo {
  // $rect-ratio: $rect-ratio * 2;
  &.large {
    margin: 90px auto 64px;
    transform: scale(1.5);
  }
  position: relative;
  height: 19 * $rect-ratio;
  width: 19 * $rect-ratio;
  background: rgba(#000, 0.7);
  .hole {
    position: absolute;
    height: 1.5 * $rect-ratio;
    width: 1.5 * $rect-ratio;
    border-radius: 50%;
    background: #fff;
    &.height {
      top: 1.5 * $rect-ratio;
    }
    &.low {
      bottom: 4.5 * $rect-ratio;
    }
  }
  .center {
    color: rgba(173, 216, 230, 0.8);
    margin: auto;
  }
  .lab-h {
    position: absolute;
    top: -2em;
    width: 100%;
    color: #000;
    &::before,
    &::after {
      content: "";
      display: block;
      height: 1px;
      flex: 1;
      background: $label-color;
    }
    &::before {
      margin-right: 0.3em;
    }
    &::after {
      margin-left: 0.3em;
    }
  }
  .lab-v {
    position: absolute;
    top: 0;
    left: -3em;
    height: 100%;
    color: #000;
    &::before,
    &::after {
      content: "";
      display: block;
      width: 1px;
      height: 50%;
      flex: 1;
      background: $label-color;
    }
    &::before {
      margin-bottom: 0.3em;
    }
    &::after {
      margin-top: 0.3em;
    }
  }
  .lab-top {
    position: absolute;
    top: -2 * $rect-ratio;
    left: 0.73 * $rect-ratio;
    color: $label-color;
    font-size: 16px;
    &::before {
      content: "";
      display: block;
      width: 1px;
      height: 2.4 * $rect-ratio;
      margin-right: 0.5em;
      background: $label-color;
    }
  }
  .lab-bot {
    position: absolute;
    bottom: -4.5 * $rect-ratio;
    left: 0.75 * $rect-ratio;
    color: $label-color;
    font-size: 16px;
    &::before {
      content: "";
      display: block;
      width: 1px;
      height: 5.3 * $rect-ratio;
      margin-right: 0.5em;
      background: $label-color;
    }
  }
}
.levels-box {
  margin-top: 40px;
  .level {
    &:not(:last-child) {
      margin-bottom: 80px;
    }
  }
}
